package org.example.task;

import com.ruoyi.common.utils.StringUtils;
import org.example.statistics.domain.StatisticsBuy;
import org.example.statistics.domain.StatisticsMonthMoney;
import org.example.statistics.domain.StatisticsSell;
import org.example.statistics.service.IStatisticsBuyService;
import org.example.statistics.service.IStatisticsMonthMoneyService;
import org.example.statistics.service.IStatisticsSellService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Calendar;

/**
 * 定时任务调度测试
 *
 * @author ruoyi
 */
@Component("demoTask")
public class DemoTask {


    @Autowired
    private IStatisticsMonthMoneyService statisticsMonthMoneyService;

    @Autowired
    private IStatisticsBuyService statisticsBuyService;

    @Autowired
    private IStatisticsSellService statisticsSellService;
    public void multipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void params(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void noParams()
    {

        // 获取当前日期的Calendar实例 将当前日期的月份减1
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, -1);


        StatisticsBuy buy= new StatisticsBuy();
        buy.setCreateTime(calendar.getTime());
        statisticsBuyService.insertStatisticsBuyByMonth(buy);


        StatisticsSell sell= new StatisticsSell();
        sell.setCreateTime( calendar.getTime());
        statisticsSellService.insertStatisticsSellByMonth(sell);
        System.out.println("执行无参方法");
       // loopTime();
    }


}
